
package ts.group.webapp.market;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.transaction.TransactionConfiguration;

import ts.group.webapp.market.model.TProductOrder;
import ts.group.webapp.market.service.IOrderService;

import com.starit.common.dao.support.Pagination;

@ContextConfiguration(locations = { "classpath:/ts-core-context.xml" })
@TransactionConfiguration(defaultRollback = true)
public class FrameworkUnit extends AbstractTransactionalJUnit4SpringContextTests {

	@Autowired
	private IOrderService orderService; 

	@Test  /*测试时间范围查询*/
	public void test(){
		String startTime = "2012-02-07 21:18:55";
		String endTime = "2012-02-07 21:20:07";
		String productCode = "A05";
		String rowSql = "from TProductOrder ord  where 1=1 and ord.productCode= '"
									+productCode+"'"+"	and ord.createTime >'"+startTime+"'"+"	and ord.createTime <'"+endTime+"'";
		String countSql = "	select count(*) 	"+ rowSql;
		
		Pagination<Object> page = orderService.findPageByHQL(rowSql, countSql, 1, 20);
		
		for(Object o :page.getResult() ){
			TProductOrder ord = (TProductOrder)o;
			System.out.println(ord.getDistributorCode());
		}
		
	}
}
